<?php


namespace app\admin\controller\v1;


use app\common\controller\BaseController;
use app\common\validate\ManagerValidate;
use app\admin\model\Manager as ManagerModel;

class Manager extends  BaseController
{
    //自动写入时间
    protected $autoWriteTimestamp = true;

    /**
     * 账号密码登录
     * @return \think\response\Json
     * @throws \app\lib\exception\BaseException
     */
    public function login()
    {
        //验证参数
        (new ManagerValidate())->goCheck('login');
        //登录
        $token = (new ManagerModel())->login();
        return self::showResCode('登录成功',['token'=>$token]);
    }

    public function getinfo()
    {
        $data = (new ManagerModel())->getInfo();
        return self::showResCode('获取成功',['data'=>$data]);
    }

    /**
     * 获取管理员列表
     * @return \think\response\Json
     */
    public function index(){
        $list = (new ManagerModel())->getList();
        return self::showResCode('获取成功',$list);
    }
}